package cn.life.business.role.service.impl;

import cn.life.business.role.dao.RoleDao;
import cn.life.business.role.entity.po.RolePo;
import cn.life.business.role.entity.vo.RoleVo;
import cn.life.business.role.service.RoleService;
import cn.life.common.entity.model.CMessage;
import cn.life.common.entity.vo.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:    用户角色Service实现层
 *
 * @Author 李佳明
 * @Date 2018-07-25 08:55
 */
@Service
public class RoleServiceImpl implements RoleService{

    @Autowired
    private RoleDao roleDao;

    @Override
    public CMessage addRole(RolePo rolePo) {
        return roleDao.addRole(rolePo) != null ? CMessage.addSuccess() : CMessage.addFail();
    }

    @Override
    public CMessage updateRole(RolePo rolePo) {
        return roleDao.updateRole(rolePo) == 1 ? CMessage.modifySuccess() : CMessage.modifyFail();
    }

    @Override
    public CMessage deleteRole(RolePo rolePo) {
        return roleDao.deleteRole(rolePo) == 1 ? CMessage.removeSuccess() : CMessage.removeFail();
    }

    @Override
    public CMessage queryRoleList(RolePo rolePo) {
        Pagination<RoleVo> list = roleDao.queryRoleList(rolePo);
        return CMessage.success("查询成功",list);
    }

    @Override
    public CMessage queryRoleDetail(RolePo rolePo) {
        RoleVo roleVo = roleDao.queryRoleDetail(rolePo);
        return CMessage.success("查询成功",roleVo);
    }
}
